#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];

void read(map<string, string>& mp) {
  string line;
  cin >> line;
  for (char& c : line)
    if (!isdigit(c) && !isalpha(c)) c = ' ';
  stringstream ss(line);
  string a, b;
  while (ss >> a >> b) mp[a] = b;
}
set<string> set_xor(map<string, string>& mp1, map<string, string>& mp2) {
  set<string> res;
  for (auto& p : mp1) {
    if (!mp2.count(p.first)) res.insert(p.first);
  }
  return res;
}
set<string> set_change(map<string, string>& mp1, map<string, string>& mp2) {
  set<string> res;
  for (auto& p : mp1) {
    if (mp2.count(p.first) && p.second != mp2[p.first]) res.insert(p.first);
  }
  return res;
}

void solve() {
  map<string, string> a;
  map<string, string> b;
  read(a);
  read(b);
  set<string> x = set_xor(b, a);
  set<string> y = set_xor(a, b);
  set<string> z = set_change(a, b);
  if (x.empty() && y.empty() && z.empty()) {
    cout << "No changes" << endl << endl;
    return;
  }
  if (x.size()) {
    bool start = true;
    for (string s : x) {
      cout << (start ? '+' : ',');
      cout << s;
      start = false;
    }
    cout << endl;
  }
  if (y.size()) {
    bool start = true;
    for (string s : y) {
      cout << (start ? '-' : ',');
      cout << s;
      start = false;
    }
    cout << endl;
  }
  if (z.size()) {
    bool start = true;
    for (string s : z) {
      cout << (start ? '*' : ',');
      cout << s;
      start = false;
    }
    cout << endl;
  }
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  // freopen("1.txt", "r", stdin);
  // freopen("2.txt", "w", stdout);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}